//JavaScript代码区域
layui.use(['element', 'table', 'jquery', 'laydate', 'form'], function () {
    var element = layui.element;
    var table = layui.table;
    var laydate = layui.laydate;
    var form = layui.form;
    // var $ = layui.jquery;
    laydate.render({
        elem: "#start_date"
    })
    laydate.render({
        elem: "#end_date"
    });
    $(function () {
        tableRender();
        form.render();
    })
    $("#find").click(function () {
        tableRender();
    })
    $("#clear").click(function () {
        $(".search_input").val("");
    })

    function tableRender() {
        table.render({
            elem: '#team_record'
            // , height: 312
            ,
            url: LOCALHOSTURL + '/team/changeUserTeamRecord/getChangeUserTeamRecords' //数据接口
            ,
            method: "get",
            where: {
                "param": $("#param").val(),
                "start_date": $("#start_date").val(),
                "end_date": $("#end_date").val()
            },
            xhrFields: {
                withCredentials: true //默认情况下，标准的跨域请求是不会发送cookie的
            },
            headers: {
                "Authorization": $.cookie("token")
            },
            crossDomain: true,
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 200 //规定成功的状态码，默认：0
            },
            page: true //开启分页
            ,
            title: "调组记录表",
            // toolbar: '#toolbar',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [
                [ //表头
                    {
                        type: 'checkbox',
                        fixed: 'left'
                    }, {
                    field: 'id',
                    title: 'ID',
                    sort: true
                }, {
                    field: 'user',
                    title: '学生姓名',
                    templet: function (res) {
                        if (res.user == null)
                            return '暂无';
                        else
                            return res.user;
                    }
                }, {
                    field: 'previousTeam',
                    title: '以前小组',
                    templet: function (res) {
                        if (res.previousTeam == null)
                            return '暂无';
                        else
                            return res.previousTeam;
                    }
                }, {
                    field: 'nowTeam',
                    title: '现在小组',
                    templet: function (res) {
                        if (res.nowTeam == null)
                            return '暂无';
                        else
                            return res.nowTeam;
                    }
                }, {
                    field: 'createTime',
                    title: '调组时间',
                    templet: function (res) {
                        return res.createTime;
                    },
                    sort: true
                }
                ]
            ]
        });
    }
});
